home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / SPX20.ZIP / SPX_DOC.ZIP / SPX_GEO.DOC < prev    next >
Text File  |  1993-09-15  |  7KB  |  201 lines

  1. { SPX Library Version 2.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.   SPX_GEO is the geomorph "tile map" handling unit.  It allows you to
  4. scroll large maps.  The maps are composed of sprites that are aligned
  5. next to each other like a tile floor.
  6.  
  7. ───────────────────────────────────────────────────────────────────────────
  8. type
  9.   Pmorph = ^Tmorph;
  10.   Tmorph = object
  11.  
  12.  
  13. VARIABLES:
  14.      gosx,gofsy:byte:   Used internally.  Indicates the pixel offset of
  15.                         the map;
  16.      ts:byte:           Used internally.  Indicates the sprite size of
  17.                         the tiles in shifted bits. ie.
  18.  
  19.                                4x4 tile  ts=2
  20.                                8x8 tile  ts=3
  21.                              16x16 tile  ts=4
  22.                              32x32 tile  ts=5
  23.      gv_width:          Width of sprites to display. (in tiles amount);
  24.      gv_height:         Height of sprites to display. (in tiles);
  25.      gmx,gmy:           Width and height of geomorph (in tiles);
  26.      gsx,gsy:           Width and height of tile (in pixels);
  27.      hvx,hvy:           Used internally; = gv_width div 2,gv_height div 2;
  28.      smapx,smapy:       Top-left corner region of geomorph;
  29.  
  30.   ---------------------------------------------------
  31.   constructor Tmorph.init(geomx,geomy,gvw,gvh,scrx,scry:integer);
  32.  
  33.      Sets up the object.
  34.  
  35.      GEOMX:     Width of geomorph (in tiles);
  36.      GEOMY:     Height of geomorph (in tiles);
  37.      GVW:       Width of tiles to display (in tiles);
  38.      GVH:       Height of tiles to display (in tiles);
  39.      SCRX,SCRY: Top-left corner region of geommorph
  40.  
  41.   ---------------------------------------------------
  42.   destructor Tmorph.done; virtual;
  43.  
  44.   Deallocates the object
  45.  
  46.   ---------------------------------------------------
  47.   function Tmorph.geomap(x,y:integer):integer;virtual;
  48.  
  49.   Returns the tile number at the (X,Y) coordinate.
  50.  
  51.     X,Y:  Tile positon of geomorph (in tiles)
  52.  
  53.   OVERRIDE: Always
  54.  
  55.   ---------------------------------------------------
  56.   procedure Tmorph.drawmap(vx,vy:integer);virtual;
  57.  
  58.   Displays the geomorph on the active page.
  59.  
  60.     VX,VY:  Center position area of geomorph to display.
  61.             (in pixels)
  62.  
  63.             VX is usually in the range 0..geomorph_width*sprite_width-1
  64.             VY is usually in the range 0..geomorph_height*sprite_height-1
  65.  
  66.     NOTES:  To use, geomorh tiles width and height must be the same, and
  67.     must be: 4x4, 8x8, 16x16, 32x32 etc.
  68.  
  69.     Change the variable (ts) to reflect sprite size
  70.  
  71.        4x4 tile    ts=2
  72.        8x8 tile    ts=3
  73.        16x16 tile  ts=4
  74.        32x32 tile  ts=5
  75.  
  76.   ---------------------------------------------------
  77.   procedure Tmorph.drawmap_wd(vx,vy:integer);virtual;
  78.  
  79.   Same as Tmorph.drawmap. Displays the geomorph on the active page.  Faster
  80.   calcuations than Tmorph.drawmap
  81.  
  82.   VX,VY:  Center position area of geomorph to display.
  83.             (in pixels)
  84.  
  85.             VX is usually in the range 0..geomorph_width*sprite_width-1
  86.             VY is usually in the range 0..geomorph_height*sprite_height-1
  87.  
  88.   NOTES:  To use, geomorh tiles width and height must be the same, and
  89.     must be: 4x4, 8x8, 16x16, 32x32 etc.
  90.  
  91.     change the variable (ts) to reflect sprite size
  92.  
  93.        4x4 tile    ts=2
  94.        8x8 tile    ts=3
  95.        16x16 tile  ts=4
  96.        32x32 tile  ts=5
  97.  
  98.   ---------------------------------------------------
  99.   procedure Tmorph.drawmap_n16(vx,vy:integer);virtual;
  100.  
  101.   Same as drawmap. Displays the geomorph on the active page
  102.  
  103.   VX,VY:  Center position area of geomorph to display.
  104.             (in pixels)
  105.  
  106.             VX is usually in the range 0..geomorph_width*sprite_width-1
  107.             VY is usually in the range 0..geomorph_height*sprite_height-1
  108.  
  109.   Tiles width and height can be any size
  110.  
  111.     Change the variables (gsx),(gsy) to the tile's width and height.
  112.  
  113.   ---------------------------------------------------
  114.   procedure Tmorph.placegeo(x,y,geonum:integer);virtual;
  115.  
  116.   Called from Tmorph.drawmap/drawmap_n16.  Displays a tile on the screen.
  117.  
  118.     X,Y:     Top-left position of tile to display;
  119.     GEONUM:  Tile number to display
  120.  
  121.   OVERRIDE: Often
  122.  
  123.   Usually your override procedure would look something like:
  124.  
  125.     procedure TMyMorph.placegeo(x,y,geonum);
  126.     begin
  127.       fput(x,y,geo_tiles[geonum]^);
  128.     end;
  129.  
  130.   ---------------------------------------------------
  131.   procedure Tmorph.placegeo_wd(nd:word;geonum:integer);virtual;
  132.  
  133.   Called from Tmorph.drawmap_wd.  Displays tile on the screen.
  134.  
  135.     ND:      Offset of the top-left position of tile to display;
  136.     GEONUM:  Tile number to display
  137.  
  138.   OVERRIDE: Often
  139.   ---------------------------------------------------
  140.   procedure Tmorph.nogogeo_wd(nd:word);virtual;
  141.  
  142.   Called from Tmorph.drawmap_wd.  Is called when a tile is
  143.   out of range.
  144.  
  145.   ---------------------------------------------------
  146.   procedure Tmorph.nogogeo(x,y:integer);virtual;
  147.  
  148.   Called from Tmorph.drawmap/drawmap_n16.  Is called when a tile is
  149.   out of range.
  150.  
  151.   ---------------------------------------------------
  152.   procedure Tmorph.pre_map; virtual;
  153.  
  154.   Called before each drawing of the geomorph.
  155.  
  156.   ---------------------------------------------------
  157.   procedure Tmorph.post_map; virtual;
  158.  
  159.   Called after each drawing of the geomorph.
  160.  
  161. ───────────────────────────────────────────────────────────────────────────
  162.  
  163. type
  164.   PHexMorph = ^THexMorph;
  165.   THexMorph = object(Tmorph)
  166.  
  167.   This desendant of Tmorph allows for irregular spacing of the tile map.
  168.  
  169. VARIABLES:
  170.       oddy,oddx:        Sets the (x,y) offset position of the odd columns
  171.       evenx,eveny:      Sets the (x,y) offset position of the even columns
  172.  
  173.       By default the above variables are set to zero. (will function like
  174.        a Tmorph object)
  175.  
  176.  
  177. ───────────────────────────────────────────────────────────────────────────
  178. function loadGMP(f:string;var piclist,map):integer;
  179.  
  180.   Load a .GMP file from disk.
  181.  
  182.   F:        DOS file name of GMP file to load;
  183.   PICLIST:  Array of pointer to hold the tiles;
  184.   MAP:      Array of byte or word to hold the map
  185.  
  186.   Returns the number of tiles in the GMP file.
  187.  
  188.   The example below loads a 100,100 GMP file:
  189.  
  190.   const
  191.     gmx  = 100;
  192.     gmy  = 100;
  193.  
  194.   var
  195.     geo_tiles : array[1..100] of pointer;
  196.     MyMap     : array[0..gmy-1,0..gmx-1] of byte;
  197.     geos      : integer;
  198.  
  199.   begin
  200.     geos := LoadGMP('MyGMP.GMP',geo_tiles,MyMap);
  201.   end;